﻿using GCC.Container.Abstracts;

namespace Z.Test.JobDemo
{
    public class JobDemo6 : AbsJobBase
    {
        public JobDemo6(AbsGCCLogger logger) : base(logger)
        {
            Name = "我专门测试转换坐标系";
        }

        public override Task Start(AbsGCCContext context)
        {
            return Task.Run(async () =>
            {
                context.TransformCoordinate("EPSG:3857", "EPSG:4326", 12113574.28, 4067402.1, out var targetX, out var targetY);
                Console.WriteLine($"targetX:{targetX}  targetY:{targetY}");

                context.TransformCoordinate("EPSG:3395",
                    "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs ",
                    "EPSG:4326", "+proj=longlat +datum=WGS84 +no_defs",
                    12113574.28, 4043331.8, out var targetX1, out var targetY1);
                Console.WriteLine($"targetX:{targetX}  targetY:{targetY}");
            }, _cancellToken.Token);
        }

        protected override void Dispose(bool flag)
        {
            Console.WriteLine($" 我是JOB:{Name} 我被销毁了.");
            base.Dispose(flag);
        }
        public override Task Stop()
        {
            return Task.Run(() =>
            {
                Logger.Information($"Job {Name} stoping.");
                _cancellToken.Cancel();
                Logger.Information($"Job {Name} stoped.");
            });
        }
    }
}